package doantotnghiep.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "SanPham")
public class Medicament {
	private int id;
	private String medicamentName;
	private float boughtPrice;
	private float sellPrice;
	private int totalOfBatch;
	private int status;
	@Id
	@GeneratedValue
	@Column(name = "MaSP")
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	
	@Column(name="TenSP")
	public String getMedicamentName() {
		return medicamentName;
	}
	
	public void setMedicamentName(String supplyName) {
		this.medicamentName = supplyName;
	}
	
	private Category category;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "MaNhom")
	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}
	
	private MeasureUnit measure;
		
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "MaDVT")
	public MeasureUnit getMeasure() {
		return measure; 
	}
	public void setMeasure(MeasureUnit measure) {
		this.measure = measure;
	}
	
	private Provider provider;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "MaNCC")
	public Provider getProvider() {
		return provider;
	}

	public void setProvider(Provider provider) {
		this.provider = provider;
	}
	
    private Set<MedicamentBatch> medicalbatchs = new HashSet<MedicamentBatch>();

    @OneToMany(mappedBy = "medicament", fetch = FetchType.LAZY) 
	@Fetch(FetchMode.JOIN)
	public Set<MedicamentBatch> getMedicalbatchs() {
		return medicalbatchs;
	}

	public void setMedicalbatchs(Set<MedicamentBatch> medicalbatchs) {
		this.medicalbatchs = medicalbatchs;
	} 	
	@OneToMany(mappedBy = "medicament",fetch=FetchType.LAZY)
	@Fetch(FetchMode.JOIN)
	public Set<PurchaseOrderDetail> getPurchaseOrderDetails() {
		return purchaseOrderDetails;
	}

	public void setPurchaseOrderDetails(Set<PurchaseOrderDetail> purchaseOrderDetails) {
		this.purchaseOrderDetails = purchaseOrderDetails;
	}
	
	@Column(name="DonGiaNhap")
	public float getBoughtPrice() {
		return boughtPrice;
	}

	public void setBoughtPrice(float boughtPrice) {
		this.boughtPrice = boughtPrice;
	}

	@Column(name="DonGiaBan")
	public float getSellPrice() {
		return sellPrice;
	}

	public void setSellPrice(float sellPrice) {
		this.sellPrice = sellPrice;
	}
	
	@Column(name = "TongSoLo")
	public int getTotalOfBatch() {
		return totalOfBatch;
	}

	public void setTotalOfBatch(int totalOfBatch) {
		this.totalOfBatch = totalOfBatch;
	}

	@Column(name ="TrangThai")
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	private Set<PurchaseOrderDetail> purchaseOrderDetails = new HashSet<PurchaseOrderDetail>(); 
	
}
